import 'package:flutter_riverpod/flutter_riverpod.dart';

import '../core/network/api_client.dart';
import '../features/home/intent/home_state.dart';
import '../features/home/model/home_viewmodel.dart';
import '../features/room_list/datasources/room_list_repository_impl.dart';
import '../features/room_list/intent/RoomListState.dart';
import '../features/room_list/model/room_list_viewmodel.dart';
import '../features/splash/datasources/splash_repository_impl.dart';
import '../features/splash/intent/splash_state.dart';
import '../features/splash/model/splash_viewmodel.dart';
import '../features/video_list/intent/video_list_state.dart';
import '../features/video_list/model/video_list_viewmodel.dart';
import '../features/video_play/intent/video_play_state.dart';
import '../features/video_play/model/video_play_viewmodel.dart';
import '../features/video_tag/datasources/video_tag_repository_impl.dart';
import '../features/video_tag/intent/video_tag_state.dart';
import '../features/video_tag/model/video_tag_viewmodel.dart';

final splashViewModelProvider = StateNotifierProvider.autoDispose<SplashViewModel, SplashState>((ref) {
  //只提供最基础的联网请求功能
  final apiClient = ApiClient();
  //开屏页面用到的获取最新版本的接口请求
  final repository = SplashRepositoryImpl(apiClient);
  return SplashViewModel(repository);
});

final homeViewModelProvider = StateNotifierProvider.autoDispose<HomeViewModel, HomeState>((ref) {
  return HomeViewModel();
});

final roomListViewModelProvider = StateNotifierProvider.autoDispose<RoomListViewModel, RoomListState>((ref) {
  final apiClient = ApiClient();
  final repository = RoomListRepositoryImpl(apiClient);
  return RoomListViewModel(repository);
});

final videoTagViewModelProvider = StateNotifierProvider.autoDispose<VideoTagViewModel, VideoTagState>((ref) {
  final apiClient = ApiClient();
  final repository = VideoTagRepositoryImpl(apiClient);
  return VideoTagViewModel(repository);
});

final videoListViewModelProvider = StateNotifierProvider.autoDispose<VideoListViewModel, VideoListState>((ref) {
  return VideoListViewModel();
});

final videoPlayViewModelProvider = StateNotifierProvider.autoDispose<VideoPlayViewModel, VideoPlayState>((ref) {
  return VideoPlayViewModel();
});